package com.longrise.android.byjk.common;

import com.longrise.android.byjk.model.UserInfor;
import com.longrise.common.datasource.local.sp.CacheUtils;
import com.longrise.common.utils.PrintLog;

/**
 * 获取系统参数设置
 * */

public class Control {

	private static final String TAG = "Control";
	/**
	 * 用户登录的账号或者身份证
	 */
	public static final String USERNAME = "username";
	
	public static final String DOWNLOADCOURSE = "downloadcourse";

	public static final String USERID = "userid";



	/**
	 * WIFI下自动更新
	 * @return 1 "是" 0 "否"
	 * */
	public static String getWiFiIsAutoUpdate(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "wifinetwork");
	}

	public static void setWiFiIsAutoUpdate(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "wifinetwork", value);
	}
	
	/**
	 * 是否允许消息通知
	 * @return 1 "是" 0 "否"
	 * */
	public static String getIsAbleNotification(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "notification");
	}

	public static void setIsAbleNotification(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "notification", value);
	}

	/**
	 * 是否允许在移动网络下播放
	 * @return 1 "是" 0 "否"
	 * */
	public static String getCellularNetWork(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "cellularnetwork");
	}

	public static void setCellularNetWork(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "cellularnetwork", value);
	}

	/**
	 * 是否允许在移动网络下载
	 * @return
     */
	public static boolean isCanMobileDownload(){
		PrintLog.d(TAG,"isCanMobileDownload:"+CacheUtils.getBoolean(UserInfor.getInstance().getUsersfzh() + "iscanmobiledownload",false));
		return CacheUtils.getBoolean(UserInfor.getInstance().getUsersfzh() + "iscanmobiledownload",false);
	}

	public static void setIsCanMobileDownload(boolean value){
		PrintLog.d(TAG,"setIsCanMobileDownload:"+value);
		CacheUtils.setBoolean(UserInfor.getInstance().getUsersfzh() + "iscanmobiledownload",value);
	}
	
	/***
	 * WIFI下是否自动缓存课程
	 * @return 1 "是" 0 "否"
	 * */
	public static String getWifiIsAutoCache(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "wifiautocache");
	}

	public static void setWifiIsAutoCache(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "wifiautocache", value);
	}
	
	
	/**
	 * 缓存路径
	 * @return "path"
	 * */
	public static String getCachePath(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "cachepath");
	}

	public static void setCachePath(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "cachepath", value);
	}
	
	/**
	 * 缓存最大空间
	 * @return "size"
	 * */
	public static String getCacheMaxSize(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "cachemaxsize");
	}

	public static void setCacheMaxSize(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "cachemaxsize", value);
	}

	/**
	 * 课程支付成功后存储支付的时间
	 * @param key 课程id
	 * @return
     */
	public static Long getPaymentTime(String key){
	  return CacheUtils.getLong(UserInfor.getInstance().getUsersfzh() + key,0);
	}

	public static void setPaymentTime(String key,long value){
		CacheUtils.setLong(UserInfor.getInstance().getUsersfzh() + key, value);
	}

	/**
	 * 缓存清晰度
	 * @return 1 “顺畅” 0 “高清”
	 * */
	public static String getDeifinition(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "cachedefinition");
	}

	public static void setDeifinition(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "cachedefinition", value);
	}
	
	/**
	 * @return 1 清空
	 * 学完课程自动清空
	 * */
	public static String getStudyVideoDone(){
		return CacheUtils.getString(UserInfor.getInstance().getUsersfzh() + "studydoneclear");
	}

	public static void setStudyVideoDone(String value){
		CacheUtils.setString(UserInfor.getInstance().getUsersfzh() + "studydoneclear", value);
	}

	/**
	 *
	 * @param areaid 地区id
	 */
    public static void setAreaid(String areaid){
		CacheUtils.setString(UserInfor.getInstance().getUserid() + "areaid",areaid);
	}

	public static String getAreaid(){
		return CacheUtils.getString(UserInfor.getInstance().getUserid() + "areaid");
	}

	/**
	 *
	 * @param areaName 地区名称
	 */
	public static void setAreaName(String areaName){
		CacheUtils.setString(UserInfor.getInstance().getUserid() + "areaName",areaName);
	}

	public static String getAreaName(){
		return CacheUtils.getString(UserInfor.getInstance().getUserid() + "areaName");
	}

	/**
	 * 设置当前app的版本号
	 */
	public static void setAppVersionCode(String appVersion){
        CacheUtils.setString("appVersionCode",appVersion);
	}

	public static String getAppVersionCode(){
        return CacheUtils.getString("appVersionCode");
	}


	/**
	 * 选择区域页面是否显示提示页
	 */
	public static void setIsChooseAreaTips(boolean isChooseAreaTips){
		CacheUtils.setBoolean("isChooseAreaTips",isChooseAreaTips);
	}

	public static boolean isChooseAreaTips(){
		return CacheUtils.getBoolean("isChooseAreaTips",false);
	}

	/**
	 *是否显示首页提示页
     */
	public static void setIsHomeFragmentTips(boolean isHomeFragmentTips){
		CacheUtils.setBoolean("isHomeFragmentTips",isHomeFragmentTips);
	}

	public static boolean isHomeFragmentTips(){
		return CacheUtils.getBoolean("isHomeFragmentTips",false);
	}

	/**
	 * 咨询详情页评论是否显示提示页
	 */
     public static void setNewsDetailComment(boolean isNewsDetailComment){
		 CacheUtils.setBoolean("isNewsDetailComment",isNewsDetailComment);
	 }
     public static boolean isNewsDetailComment(){
		 return CacheUtils.getBoolean("isNewsDetailComment",false);
	 }

	/**
	 * 是否显示引导页
     */
	 public static void setGuideView(boolean isGuideView){
		 CacheUtils.setBoolean("isGuideView",isGuideView);
	 }
	 public static boolean isGuideView(){
		 return CacheUtils.getBoolean("isGuideView",false);
	 }

	/**
	 * 当前APP最新版本的版本号
	 */
	public static void setLatestVersion(int version){
		CacheUtils.setLong("latestversion",version);
	}

	public static int getLatestVersion(){
		return (int) CacheUtils.getLong("latestversion");
	}

	/**
	 * 当前app最新版本的版本名称
	 */
	public static void setLatestVersionName(String versionName){
		CacheUtils.setString("latestversionname",versionName);
	}

    public static String getLatestVersionName(){
		return CacheUtils.getString("latestversionname");
	}

	/**
	 * 上传产品费率的时候给一个默认值
	 * @param number 产品的标记number
	 */
	public static void setProductNumber(int number){
		CacheUtils.setInt(UserInfor.getInstance().getUsersfzh() + "productnumber",number);
	}

	public static int getProductNumber(){
		return CacheUtils.getInt(UserInfor.getInstance().getUsersfzh() + "productnumber",1);
	}

	/**
	 * 设置,获取用户关闭通知开关的时间
	 */
	public static void setNotificationSwitchCloseTime(String time){
		CacheUtils.setString("bbNotificationSwitch",time);
	}

	public static String getNotificationSwitchCloseTime(){
		return CacheUtils.getString("bbNotificationSwitch", "");
	}

	/**
	 * 积分兑换--展业秀页面底部是否显示tips
	 */
	public static void setIsShowzxyxzTips(boolean flag){
		CacheUtils.setBoolean(UserInfor.getInstance().getUserid()+"bbIsShowzxyxzTips",flag);
	}

	public static boolean getIsShowzxyxzTips(){
		return CacheUtils.getBoolean(UserInfor.getInstance().getUserid()+"bbIsShowzxyxzTips",true);
	}

	/**
	 * 积分任务--每日任务页面底部是否显示tips
	 */
	public static void setIsShowDailyTaskTips(boolean flag){
		CacheUtils.setBoolean(UserInfor.getInstance().getUserid()+"bbIsShowDailyTaskTips",flag);
	}

	public static boolean getIsShowDailyTaskTips(){
		return CacheUtils.getBoolean(UserInfor.getInstance().getUserid()+"bbIsShowDailyTaskTips",true);
	}

	/**
	 * 收件信息--获取保存收件人姓名
	 */
	public static void setRecipientName(String name){
		CacheUtils.setString(UserInfor.getInstance().getUserid()+"byRecipientName",name);
	}

	public static String getRecipientName(){
		return CacheUtils.getString(UserInfor.getInstance().getUserid()+"byRecipientName", "");
	}

	/**
	 * 收件信息--获取保存收件人电话
	 */
	public static void setRecipientTel(String telphone){
		CacheUtils.setString(UserInfor.getInstance().getUserid()+"byRecipientTel",telphone);
	}

	public static String getRecipientTel(){
		return CacheUtils.getString(UserInfor.getInstance().getUserid()+"byRecipientTel", "");
	}

	/**
	 * 收件信息--获取保存收件地址
	 */
	public static void setRecipientAdd(String address){
		CacheUtils.setString(UserInfor.getInstance().getUserid()+"byRecipientAdd",address);
	}

	public static String getRecipientAdd(){
		return CacheUtils.getString(UserInfor.getInstance().getUserid()+"byRecipientAdd", "");
	}

}
